package users

import (
	"power/core/dao/table"
	"power/core/dao/userdao"
	"power/core/localwrap"
)

var logUsers = localwrap.GetLogger().Fork("power/core/service/users", "Users")

type Users struct{}

func (s Users) Query(param userdao.UsersQueryParam) ([]table.User, int64) {
	logUsers.Debug().Func("Query").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return userdao.Users{RedisedMysql: d}.Query(param)
}

func (s Users) Get(id int) table.User {
	logUsers.Debug().Func("Get").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return userdao.Users{RedisedMysql: d}.Get(id)
}

func (s Users) Add(param userdao.UsersAddParam) table.User {
	logUsers.Debug().Func("Add").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return userdao.Users{RedisedMysql: d}.Add(param)
}

func (s Users) Update(param userdao.UsersUpdateParam) {
	logUsers.Debug().Func("Update").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	userdao.Users{RedisedMysql: d}.Update(param)
}

func (s Users) Delete(id int) {
	logUsers.Debug().Func("Delete").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	userdao.Users{RedisedMysql: d}.Delete(id)
}
